import { BasicColumn, FormSchema } from '@/components/Table';
import { h } from 'vue';
import { Switch, Tag } from 'ant-design-vue';
import { getLevelSelectsApi, getCategorySelectsApi } from '@/api/sys/common';

import { useMessage } from '@/hooks/web/useMessage';

type CheckedType = boolean | string | number;
export const columns: BasicColumn[] = [
  {
    title: '姓名',
    dataIndex: 'userName',
  },
  {
    title: '积分',
    dataIndex: 'integral',
    width: 180,
  },
  // {
  //   title: '获得积分的类型',
  //   dataIndex: 'readType',
  //   width: 120,
  //   customRender: ({ record }) => {
  //     const isRead = record.isRead;
  //     const enable = ~~isRead === 1;
  //     const color = enable ? 'green' : 'red';
  //     const text = enable ? '是' : '否';
  //     return h(Tag, { color: color }, () => text);
  //   },
  // },
  {
    title: '系统信息',
    dataIndex: 'note',
    width: 180,
  },
  {
    title: '创建时间',
    dataIndex: 'createTime',
    width: 180,
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'keyword',
    label: '姓名',
    component: 'Input',
    colProps: { span: 8 },
  },
  // {
  //   field: 'isRead',
  //   label: '是否参与读书',
  //   component: 'Select',
  //   componentProps: {
  //     options: [
  //       { label: '否', value: '0' },
  //       { label: '是', value: '1' },
  //     ],
  //   },
  //   colProps: { span: 8 },
  // },
];

export const formSchema: FormSchema[] = [
  {
    field: 'userName',
    label: '成员名称',
    required: true,
    component: 'Input',
  },
  {
    label: '职级',
    field: 'levelName',
    component: 'ApiSelect',
    componentProps: {
      api: getLevelSelectsApi,
      // mode:"multiple",
      resultField: 'data',
      labelField: 'label',
      valueField: 'value',
    },
    required: true,
  },
  {
    field: 'isRead',
    label: '是否参与读书',
    component: 'Select',
    componentProps: {
      options: [
        { label: '否', value: 0 },
        { label: '是', value: 1 },
      ],
    },
  },
];
